package com.huijie.core.util;

import com.huijie.core.bean.BussinessMsg;
import com.huijie.core.constant.BussinessCode;

/**
 * @ClassName BussinessMsgUtil
 * @Description Restful Api 业务返回码工具类
 * @Author Alex
 * @Date 2018/9/20 19:45
 * @Version 1.0
 */
public class BussinessMsgUtil {

    /**
     * @param bussinessCode 业务返回码和对应返回描述枚举
     * @return com.cn.rfid.model.vo.base.BussinessMsg
     * @description: 返回消息代码code 和 消息描述message
     * @author Alex
     * @date 2018/9/21 8:48
     */
    public static BussinessMsg returnCodeMessage(BussinessCode bussinessCode) {
        return returnCodeMessage(bussinessCode, null);
    }

    /**
     * @param bussinessCode 业务返回码和对应返回描述枚举
     * @param returnData 返回数据
     * @return com.cn.rfid.model.vo.base.BussinessMsg
     * @description: 返回消息代码code 和 消息描述message 和 数据节点data
     * @author Alex
     * @date 2018/9/21 9:15
     */
    public static BussinessMsg returnCodeMessage(BussinessCode bussinessCode, Object returnData) {
        BussinessMsg bussinessMsg = new BussinessMsg();
        bussinessMsg.setReturnCode(bussinessCode.getCode());
        bussinessMsg.setReturnMessage(bussinessCode.getMessage());
        bussinessMsg.setReturnData(returnData);
        return bussinessMsg;
    }
}
